package com.ram.controller;

import com.ram.pojo.AssetAssignment;
import com.ram.pojo.Result;
import com.ram.service.AssetAssignmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/asset/assignment")
public class AssetAssignmentController {
    @Autowired
    private AssetAssignmentService assignmentService;

    @GetMapping("/list")
    public Result list() {
        return Result.success(assignmentService.list());
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id) {
        return Result.success(assignmentService.getById(id));
    }

    @PostMapping
    public Result add(@RequestBody AssetAssignment assignment) {
        assignmentService.add(assignment);
        return Result.success();
    }

    @PutMapping
    public Result update(@RequestBody AssetAssignment assignment) {
        assignmentService.update(assignment);
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        assignmentService.deleteById(id);
        return Result.success();
    }
} 